
#include<SDL.h>                /*使用SDL库，加载该库的头文件*/
#include<stdlib.h>
#include<unistd.h>
int main()
{
	SDL_Surface *screen;                            /*屏幕指针*/
	Uint32 color;                                   /*定义一个颜色值*/
	/*	int x;*/
	if(SDL_Init(SDL_INIT_VIDEO)<0)
	{     /*初始化视频子系统失败*/
		fprintf(stderr,"无法初始化SDL：%s\n",SDL_GetError());
		exit(1);
	}
	screen=SDL_SetVideoMode(640,480,16,SDL_SWSURFACE);  /*设置视频模式*/
	if(screen==NULL)
	{
		fprintf(stderr,"无法设置640x480x16位色的视频模式：%s",SDL_GetError());
		exit(1);
	}
	atexit(SDL_Quit);                               /*退出*/
	for(int r=0;r<=255;++r) {
		for(int g=0;g<=255;++g) {
			for(int b=0;b<=255;++b) {
				color=SDL_MapRGB(screen->format,r,g,b);
				/*SDL_MapRGB函数用来设置颜色*/
				SDL_FillRect(screen,NULL,color);                /*填充整个屏幕*/
				SDL_UpdateRect(screen,0,0,0,0);                 /*更新整个屏幕*/
				SDL_Delay(5);
			}
			SDL_Delay(5);
		}
		SDL_Delay(5);
	}
/*	SDL_Delay();*/
	SDL_Delay(3000);            /*停留3秒钟的时间*/
	return 0;
}
